package com.bianmaba.oauth2.clientcredentials.web;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xujingfeng on 2017/8/7.
 */
@RestController
public class TestEndpoints {

    @GetMapping("/product/{id}")
    public Map<String, String> getProduct(@PathVariable String id) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Map<String, String> data = new HashMap<String, String>();
        data.put("id", id);
        return data;
    }

    @GetMapping("/order/{id}")
    public Map<String, String> getOrder(@PathVariable String id) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Map<String, String> data = new HashMap<String, String>();
        data.put("id", id);
        return data;
    }

}
